import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-10-09
 * Time: 9:23
 */
public class Solution {
    public boolean isPalindrome(String s) {
        StringBuilder ss = new StringBuilder();
        Stack<Character> stack = new Stack();
        String string = s.toLowerCase();
        for(int i = 0; i < string.length(); i++) {
            char ch = string.charAt(i);
            if(ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9'){
                stack.push(ch);
                ss.append(ch);
            }
        }
        for(int i = 0; i < ss.length()/2; i++) {
            char ch1 = stack.pop();
            char ch2 = ss.charAt(i);
            if(ch1 != ch2) {
                return false;
            }
        }
        return true;
    }
}
